package com.xqboss.apps.enums.sys;

import com.xqboss.common.enums.BaseEnum;
import com.xqboss.common.exception.ServiceException;

import java.util.Objects;

/**
 * @author Administrator
 * @date 2023/8/17
 */
public enum JobConfigTypeEnum implements BaseEnum<Integer> {

    CLOSE(1, "关闭任务"),
    OPEN(2, "开启任务"),
    EXPIRE(3, "过期任务");

    private Integer value;
    private String msg;

    JobConfigTypeEnum(Integer value, String desc) {
        this.value = value;
        this.msg = desc;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    public static JobConfigTypeEnum getType(Integer type){
        for (JobConfigTypeEnum value : JobConfigTypeEnum.values()) {
            if (Objects.equals(type,value.value)) {
                return value;
            }
        }
        throw new ServiceException("类型错误~");
    }

    public static JobConfigTypeEnum getChangeType(Integer type){
        for (JobConfigTypeEnum value : JobConfigTypeEnum.values()) {
            if (Objects.equals(type,value.value) && value==CLOSE) {
                return OPEN;
            }
            if (Objects.equals(type,value.value) && value==OPEN) {
                return CLOSE;
            }
        }
        throw new ServiceException("类型错误~");
    }
}
